{extend name="extra@admin/content"}

{block name="content"}
<form onsubmit="return false;" action="__SELF__" data-auto="true" method="post" class='layui-form' style='padding-top:20px'>
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            {if $info and isset($info.title)}
            <input name="title" value='{$info.title|default=""}'
                   required="required" title="请输入标题" maxlength="20" placeholder="请输入标题" class="layui-input ">
            {else}
            <input name="title" value='{$info.title|default=""}' maxlength="20" required="required"
                   title="请输入标题" class="layui-input">
            {/if}
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">推荐商品</label>
        <div class="layui-input-block">
            <select name="goods_id" lay-verify="required" lay-filter="test" lay-search>
                <option value="">请选择推荐商品</option>
                {volist name='goods' id='v'}
                <option value="{$v.id}" {if condition="$info['goods_id'] eq $v['id']"} selected {/if}>{$v.name}</option>
                {/volist}
            </select>
        </div>
    </div>

    <!--商品logo  start-->
    <div class="layui-form-item">
        <label class="layui-form-label">PC图片 *</label>
            <div class="uploadimage" style="margin-left:1%;">
                <input type="hidden"  name="pc_logo" value="{if condition='!empty($info.pc_logo)'} {$info.pc_logo} {/if}" />
            </div>
            <a data-file="one" data-field="pc_logo" data-type="png,jpg,jpeg" data-uptype="qiniu" href="javascript:void(0)"
               class="uploadbutton"><i style="font-size:30px;" class="fa fa-upload" title="点击上传"></i></a>
            {if $info and !empty($info.pc_logo)}
            <script>
                $(function(){
                    var img = "{$info.pc_logo}";
                    require(['jquery'], function () {
                        $('[name="pc_logo"]').parent().attr('data-tips-image', this.value).css('backgroundImage', 'url(' + img + ')');
                    });
                });
            </script>
            {/if}
            <script>
                require(['jquery'], function () {
                    $('[name="pc_logo"]').on('change', function () {
                        $(this).parent().attr('data-tips-image', this.value).css('backgroundImage', 'url(' + this.value + ')');
                    });
                });
            </script>
    </div>
    <!--商品logo  end-->

    <!--商品logo  start-->
    <div class="layui-form-item">
        <label class="layui-form-label">移动图片 *</label>
            <div class="uploadimage" style="margin-left:1%;">
                <input type="hidden"  name="m_logo" value="{if condition='!empty($info.m_logo)'} {$info.m_logo} {/if}" />
            </div>
            <a data-file="one" data-field="m_logo" data-type="png,jpg,jpeg" data-uptype="qiniu" href="javascript:void(0)"
               class="uploadbutton"><i style="font-size:30px;" class="fa fa-upload" title="点击上传"></i></a>
            {if $info and !empty($info.m_logo)}
            <script>
                $(function(){
                    var img = "{$info.m_logo}";
                    require(['jquery'], function () {
                        $('[name="m_logo"]').parent().attr('data-tips-image', this.value).css('backgroundImage', 'url(' + img + ')');
                    });
                });
            </script>
            {/if}
            <script>
                require(['jquery'], function () {
                    $('[name="m_logo"]').on('change', function () {
                        $(this).parent().attr('data-tips-image', this.value).css('backgroundImage', 'url(' + this.value + ')');
                    });
                });
            </script>
    </div>
    <!--商品logo  end-->


    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            {if $info and isset($info.dis_order)}
            <input name="dis_order" value='{$info.dis_order|default=""}'
                   required="required" title="请输入1~1000之间的整数" pattern="^([1-9]\d{0,2}|1000)$" placeholder="请输入1~1000之间的整数" class="layui-input ">
            {else}
            <input name="dis_order" value='{$info.dis_order|default=""}'pattern="^([1-9]\d{0,2}|1000)$" required="required"
                   title="请输入1~1000之间的整数" class="layui-input">
            {/if}
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    <div class="col-sm-4 col-sm-offset-2">
        {if $info and isset($info.id)}<input type='hidden' value='{$info.id}' name='id'/>{/if}
        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存</button>
        </div>
    </div>
    <script type="text/javascript">
    layui.use('form', function(){
        var form = layui.form;      //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });

    form.on('select(test)', function(data){

    });
</script>
</form>

{/block}